<!-- TrainStudentStudyIndex.html -->
<!doctype html>
<!--suppress ALL -->
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>学生学习 底部导航</title>
		<link rel="stylesheet" type="text/css" href="./css/api.css"/>
		<link rel="stylesheet" type="text/css" href="./css/style.css"/>
		<link rel="stylesheet" type="text/css" href="./css/base.css"/>
		<style>
			body {
				background-color: #fff;
			}
			#footer {
				background-color: #fff;
				height: 52px;
				overflow: hidden;
			}
			#footer ul li {
				padding-top: 32px;
				padding-bottom: 4px;
				background: url() no-repeat center 4px;
				background-size: auto 24px;
				text-align: center;
				color: #979797;
				font-size: 12px;
			}
			#footer ul li.active {
				color: #18b4ed;
			}
			#footer ul li:nth-child(1) {
				background-image: url(./icon/icon_xuexi_normal.png);
			}
		    #footer ul li:nth-child(2) {
				background-image: url(./icon/icon_ketang.png);
			}
			 #footer ul li:nth-child(3) {
				background-image: url(./icon/icon_select_course_normal.png);
			}
			#footer ul li:nth-child(1).active {
				background-image: url(./icon/icon_xuexi_selected.png);
			}
			#footer ul li:nth-child(2).active {
				background-image: url(./icon/icon_ketang1.png);
			}
			 #footer ul li:nth-child(3).active {
				background-image: url(./icon/icon_select_course_selected.png);
			}
			.redPointMessage{
				top:0px;
				left: 74px;
			}
		</style>
	</head>
	<body>
		<!-- <div id="white_div"></div> -->
		<div id="wrap" class="flex-wrap flex-vertical">
			<div id="main" class="flex-con"></div>
			<div id="footer" class="border-t">
				<ul class="flex-wrap" >
					<li tapmode="hover" onclick="randomSwitchBtn( this, 0 );" class="flex-con active" >
						学习
					</li>
					<li tapmode="hover" onclick="randomSwitchBtn( this, 1 );" class="flex-con " style="position:relative;" >
						课堂
						<div id="footer_kt" class="redPointMessage"></div>
					</li>
					<!-- <li tapmode="hover" onclick="randomSwitchBtn( this, 2 );" class="flex-con" >
						选课
					</li> -->
				</ul>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="script/api.js"></script>
	<script type="text/javascript" src="script/requestTool.js"></script>
	<script type="text/javascript" src="script/databaseOperation.js"></script>
	<script type="text/javascript" src="script/jquery.min.js"></script>
	<!-- <script type="text/javascript" src="script/TrainUploadLearningRecord.js"></script> -->
	<script type="text/javascript">
		DBReady = function() {
			//设置学习记录上传更新
			// setupUploadRecord();
			setupNotifi();
			setupGroup();
			//课堂消息处理
            classrommMessage();
            api.addEventListener({
                name: 'pushMessage_classroom'
            }, function(ret, err) {
                //课堂消息处理
                classrommMessage();
            });
            api.addEventListener({
                name: 'pushMessage_classroom_hide'
            }, function(ret, err) {
                //课堂消息处理
                $('#footer_kt').hide();
            });

            api.sendEvent({
                name: 'click_pushMessage_index'
            });
		}

        /**
         * 处理课堂红点消息
         */
		function classrommMessage() {
            //课堂消息处理
            var jid = $api.getStorage('cfnetppjxid');
            var classroom = $api.getStorage('cfnetppmessageclassroom' + jid);
            console.log("classroom : " +classroom);
            if(classroom == 1){
                $('#footer_kt').show();
            }else{
                $('#footer_kt').hide();
            }
        }

		function setupNotifi() {
			api.addEventListener({
				name : 'offlineCloseWinNotifi'
			}, function(ret, err) {

			  api.closeWin({
               });

			});
			//安卓下按2返回键退出
			var currentClickNum = 0;
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				api.closeWin({
				});
			});
		}

		function setupGroup() {
			var eHeaderLis = $api.domAll('header li'), frames = [];
			//添加学习页
			frames.push({
				name : 'Student_studyWindow',
				url : 'html/Study/Student_studyWindow.html',
				
				bgColor : '#fff',
				bounces : false,
				vScrollBarEnabled : false,
				pageParam : {
					sourceurl : api.pageParam.sourceurl,
					sourcetitle : api.pageParam.sourcetitle,
					type : 'Certification',
					Type : 0,
					ifteacherstudy:'false',//是否是老师端学习
				}
			});
			//课堂
			frames.push({
				// name : 'liveStreamListWindow',
				// url : 'html/CourseManage/liveStreamListWindow.html',
				name : 'Study_classWindow',
				url : 'html/Student_Classroom/Study_classWindow.html',
				bgColor : '#fff',
				bounces : false,
				vScrollBarEnabled : false,
				hScrollBarEnabled : false,
				pageParam : {
					sourceurl : api.pageParam.sourceurl,
					sourcetitle : api.pageParam.sourcetitle,
					type : 'Certification'
				}
			});
			//添加选课中心
			frames.push({
				name : 'TrainMine',
				url : 'html/CourseCenter/CourseCenter_CourseListWindow.html',
				bgColor : '#fff',
				bounces : false,
				reload : true,
				vScrollBarEnabled : false,
				hScrollBarEnabled : false,
				pageParam : {
					sourceurl : api.pageParam.sourceurl,
					sourcetitle : api.pageParam.sourcetitle,
					type : 'Certification'
				}
			});
			var bottomH = $api.byId('footer').offsetHeight;
			//52
			var y = 0;
			//y : $api.dom('header').offsetHeight,
			var h = api.winHeight - bottomH;
			//h : $api.dom('#main').offsetHeight
			api.openFrameGroup({
				name : 'group',
				background : '#fff',
				scrollEnabled : false,
				rect : {
					x : 0,
					y : y,
					w : api.winWidth,
					h : h
				},
				index : 0,
				frames : frames,
				preload : 0
			}, function(ret, err) {
			});
		}

		// 随意切换按钮
		function randomSwitchBtn(tag, num) {
			//设置tabbar选中下标
			$api.setStorage('tabbarSelectedIndex', num);
			var eFootLis = $api.domAll('#footer li'), eHeaderLis = $api.domAll('header li'), index = 0;
			for (var i = 0, len = eFootLis.length; i < len; i++) {
				if (tag == eFootLis[i]) {
					index = i;
				} else {
					$api.removeCls(eFootLis[i], 'active');
					$api.removeCls(eHeaderLis[i], 'active');
				}
			}
			$api.addCls(eFootLis[index], 'active');
			$api.addCls(eHeaderLis[index], 'active');
			api.setFrameGroupIndex({
				name : 'group',
				index : index
			});
			if (num == 0) {
				api.sendEvent({
					name : 'showCourseFrameGroupNotifi'
				});
			} else {
				api.sendEvent({
					name : 'hideCourseFrameGroupNotifi'
				});
			}
			if (num == 1) {
				api.sendEvent({
					name : 'showStudy_classNotifi'
				});
			} else {
				api.sendEvent({
					name : 'hideStudy_classNotifi'
				});
			}
			// if (num == 1) {
			// 	api.sendEvent({
			// 		name : 'showClassroomFrameNotifi'
			// 	});
			// } else {
			// 	api.sendEvent({
			// 		name : 'hideClassroomFrameNotifi'
			// 	});
			// }
			if (num == 2) {
				api.sendEvent({
					name : 'showCourseCenterListNotifi'
				});
			}else{
				api.sendEvent({
					name : 'hideCourseCenterListNotifi'
				});
			}
			// if (num != 2) {
			// 	api.sendEvent({
			// 		name : 'hideOfflineAlertNotifi'
			// 	});
			// }
		}
	</script>
</html>